<template>
	<view>
		<view class="statbar"></view>
		<view style="margin: 20px;">
			<u-search placeholder="请输入剧名" :clearabled="true" v-model="keyword" :showAction="true" @search="search" :actionText="actionText" @custom="custom"
				@clear="keyword=''" @blur="blur" @focus="focus"></u-search>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				actionText: '取消',
				keyword:''
			}
		},
		methods: {
			search(value) {
				uni.$u.route({
					url: 'pages/list/list-page',
					params: {
						keyword: value,
						navText: "搜索 "+value+" 结果"
					}
				})
			},
			custom(value) {
				console.log(this.actionText)
				if (this.actionText == '搜索') {
					uni.$u.route({
						url: 'pages/list/list-page',
						params: {
							keyword: value
						}
					})
				} else if (this.actionText == '取消') {
					uni.$u.route({
						type: 'navigateBack',
						url: 'pages/home/home'
					})

				}
			},
			blur(){
				setTimeout(()=>{
					this.actionText="取消"
				},500)
				
			},
			focus(){
				this.actionText="搜索"	
			}
		}
	}
</script>

<style lang="scss" scoped>
  .statbar {
		height: var(--status-bar-height);
		background: #FFFFFF;
	}
</style>
